package com.dandan.testcollection.touch;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

/**
 * Created by Dandan on 2018/6/22.
 */

public class ViewTouchTest extends View
{

    public ViewTouchTest(Context context) {
        this(context,null);
    }

    public ViewTouchTest(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs,0);
    }

    public ViewTouchTest(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        Paint paint = new Paint();
        paint.setColor(Color.parseColor("#ff0000"));
        canvas.drawCircle(getWidth()/2,getHeight()/2,getWidth()/2,paint);
        super.onDraw(canvas);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        switch (event.getAction())
        {
            case MotionEvent.ACTION_DOWN:
                System.out.println("down  ----------------  down");
                break;
            case MotionEvent.ACTION_MOVE:
                System.out.println("ACTION_MOVE  ----------------  ACTION_MOVE");
                break;
            case MotionEvent.ACTION_UP:
                System.out.println("up  ----------------  up");
                break;
        }

        return true;
    }
}
